//
//  FLMDeatilListHeaderView.m
//  FLMSuperS
//
//  Created by xiaoyang on 16/10/8.
//  Copyright © 2016年 FaLaoMiaoNetworkTechnologyCo. All rights reserved.
//

#import "FLMDeatilListHeaderView.h"
#import "FLMDeatilListModel.h"
@interface FLMDeatilListHeaderView ()<SDCycleScrollViewDelegate>

@property (nonatomic, strong) SDCycleScrollView      * lunboV; //轮播视图
@property (nonatomic, strong) NSArray                *lubModelArray;

@end

@implementation FLMDeatilListHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self layoutUI];
        //        self.backgroundColor = white;
    }
    
    return self;
}

- (NSArray *)lubModelArray
{
    if (!_lubModelArray) {
        _lubModelArray = [[NSArray alloc]init];
    }
    
    return _lubModelArray;
}

- (void)layoutUI
{
    [self cycleScrollview];
    [self deatilGoodsV];
}

- (void)deatilGoodsV
{
    
    [self addSubview:self.deatilGoodsImageView];
    [self addSubview:self.bigTitleL];
    [self addSubview:self.sellLbl];
    [self addSubview:self.fanLiL];
    [self addSubview:self.sellNumL];
    [self addSubview:self.wenXinTiXing];
    
    
    [self addSubview:self.priceLabel];
    [self addSubview:self.volumeLabel];
    [self addSubview:self.fanLiLabel];
    
    [self addSubview:self.lineView];
    [self addSubview:self.shaiHaoTu];
    
    
    [self addSubview:self.oneLineView];
    [self addSubview:self.twoLineView];
    
}


#pragma mark --------------------
#pragma mark 主图
- (UIImageView *)deatilGoodsImageView
{
    if (!_deatilGoodsImageView) {
        _deatilGoodsImageView =[[UIImageView alloc]initWithFrame: CGRectMake(0, 0, ScreenW, ScreenW*2/3)];
        
        _deatilGoodsImageView.image = [UIImage imageNamed:@"1"];
    }
    return _deatilGoodsImageView;
}

#pragma mark --------------------
#pragma mark 大标题
- (SLable *)bigTitleL
{
    if (!_bigTitleL) {
        _bigTitleL = [[SLable alloc] initWithFrame:CGRectMake(10, _lunboV.bottom, ScreenW, 60) Text:@"iphone7Plus大促销大减价开来买买买仅需998真的99😯仅需九九八买买买吧" Font:15 Color:black textAligMent:NSTextAlignmentLeft];
        _bigTitleL.numberOfLines = 0;
    }
    return _bigTitleL;
}


#pragma mark --------------------
#pragma mark 售价标题
- (SLable *)priceLabel
{
    if (!_priceLabel) {
        _priceLabel = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(10), _bigTitleL.bottom+(GETHEIGHT(0)), GETSIZE(70), GETHEIGHT(25)) Text:@"售价:" Font:15 Color:gray textAligMent:NSTextAlignmentLeft];
    }
    return _priceLabel;
}

#pragma mark --------------------
#pragma mark 售价价格
- (SLable *)sellLbl
{
    if (!_sellLbl) {
        _sellLbl = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(80), _bigTitleL.bottom, GETSIZE(80), GETHEIGHT(25)) Text:@"¥998" Font:15 Color:Red textAligMent:NSTextAlignmentLeft];
    }
    return _sellLbl;
}


#pragma mark --------------------
#pragma mark 销量标题
- (SLable *)volumeLabel
{
    
    if (!_volumeLabel) {
        _volumeLabel = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(10), _bigTitleL.bottom+(GETHEIGHT(25)), GETSIZE(70), GETHEIGHT(25)) Text:@"销量:" Font:15 Color:gray textAligMent:NSTextAlignmentLeft];
    }
    return _volumeLabel;
}

#pragma mark --------------------
#pragma mark 销量
- (SLable *)sellNumL
{
    if (!_sellNumL) {
        _sellNumL = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(80), _bigTitleL.bottom+GETHEIGHT(25), GETSIZE(80), GETHEIGHT(25)) Text:@"65463   件" Font:15 Color:gray textAligMent:NSTextAlignmentLeft];
    }
    return _sellNumL;
}

#pragma mark --------------------
#pragma mark 预估返利标题
- (SLable *)fanLiLabel
{
    
    if (!_fanLiLabel) {
        _fanLiLabel = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(10), _bigTitleL.bottom+(GETHEIGHT(50)), GETSIZE(70), GETHEIGHT(25)) Text:@"预估返利:" Font:15 Color:gray textAligMent:NSTextAlignmentLeft];
    }
    return _fanLiLabel;
}



#pragma mark --------------------
#pragma mark 返利
- (SLable *)fanLiL
{
    if (!_fanLiL) {
        _fanLiL = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(80), _bigTitleL.bottom+GETHEIGHT(50), GETSIZE(80), GETHEIGHT(25)) Text:@"5％" Font:15 Color:black textAligMent:NSTextAlignmentLeft];
    }
    return _fanLiL;
}

#pragma mark --------------------
#pragma mark 温馨提醒
- (SLable *)wenXinTiXing
{
    if (!_wenXinTiXing) {
        _wenXinTiXing = [[SLable alloc]initWithFrame:CGRectMake(GETSIZE(10), _fanLiL.bottom, ScreenW, GETHEIGHT(25)) Text:@"温馨提醒 : 登录超级买账号进行购买可获一定的奖励哦" Font:13 Color:gray textAligMent:NSTextAlignmentLeft];
    }
    return _wenXinTiXing;
}



#pragma mark --------------------
#pragma mark 两条分割线
- (UIView *)oneLineView
{
    
    if (!_oneLineView){
        
        for (NSInteger i = 0; i < 1; i++){
            _oneLineView =  [[UIView alloc]initWithFrame:CGRectMake(0+i*(ScreenW/2+GETSIZE(40)), _fanLiL.bottom + GETHEIGHT(40), ScreenW/2-GETSIZE(40), GETSIZE(0.5))];
            _oneLineView.backgroundColor = gray;
            
        }
        
    }
    return _oneLineView;
}

- (UIView *)twoLineView
{
    
    if (!_twoLineView)
    {
        
        _twoLineView =  [[UIView alloc]initWithFrame:CGRectMake((ScreenW/2+GETSIZE(40)), _fanLiL.bottom + GETHEIGHT(40), ScreenW/2-GETSIZE(40), GETSIZE(0.5))];
        _twoLineView.backgroundColor = gray;
        
    }
    return  _twoLineView;
}

#pragma mark --------------------
#pragma mark 商品推荐
- (SLable *)shaiHaoTu
{
    if (!_shaiHaoTu) {
        
        _shaiHaoTu = [[SLable alloc]initWithFrame:CGRectMake( ScreenW/2-GETSIZE(40), _fanLiL.bottom+GETHEIGHT(23), GETSIZE(80), GETHEIGHT(25)) Text:@"商品推荐" Font:12 Color:gray textAligMent:NSTextAlignmentCenter];
        
    }
    return _shaiHaoTu;
}




#pragma mark 图片轮播主图
- (void)cycleScrollview{
    
    //网络图片实现
    NSArray *imagesURLStrings = @[
                                  @"http://img.25pp.com/ppnews/zixun_img/a23/24b/1470471155225728.jpg",@"http://img.zgxue.com/jbpic/file_images/article/201608/20160829112225111.jpg"
                                  ];
    
    //网络加载图片轮播器
    CGRect frame = CGRectMake(0, 0, ScreenW, ScreenW*2/3);
    self.lunboV = [SDCycleScrollView cycleScrollViewWithFrame:frame delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    self.lunboV.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
    
    self.lunboV.currentPageDotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色
    [self addSubview:self.lunboV];
    
    //加载延迟
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.lunboV.imageURLStringsGroup = imagesURLStrings;
    });
    
    //     block监听点击方式
    __weak typeof (self) weakSelf = self;
    self.lunboV.clickItemOperationBlock = ^(NSInteger index) {
        NSLog(@">>>>>  %ld", (long)index);
        if (!weakSelf.lubModelArray.count) {
            return ;
        }
        FLMGoodsDetailListModel *lunboModel = weakSelf.lubModelArray[index];
        if (weakSelf.bannarClickBlock) {
            weakSelf.bannarClickBlock(lunboModel.short_click_url);
        }
    };
    
    
}

#pragma mark -- 设置数据
- (void)configBannarView:(NSArray *)pics menuArr:(NSArray *)menuArr
{
    //轮播配置数据
    _lubModelArray = pics;
    NSMutableArray *picUrls = [[NSMutableArray alloc]init];
    for (FLMGoodsDetailListModel *lbModel in pics) {
        [picUrls addObject:lbModel.pict_url];
    }
    self.lunboV.imageURLStringsGroup = picUrls;
}

- (void)configueCellWithModel:(FLMGoodsDetailListModel *)detailListModels
{
    
    /** 商品主图 */
    [_deatilGoodsImageView sd_setImageWithURL:[NSURL URLWithString:detailListModels.pict_url] placeholderImage:[UIImage imageNamed:@"1"]];
    /** 大标题 */
    _bigTitleL.text =  detailListModels.title;
    /** 售价 */
    _sellLbl.text = [NSString stringWithFormat:@"¥%@",detailListModels.zk_final_price];
    /** 销量 */
    _sellNumL.text = [NSString stringWithFormat:@"%@",detailListModels.volume];
    /** 返利 */
    _fanLiL.text = [NSString stringWithFormat:@"%@",detailListModels.zk_final_price];
    
}

@end
